package ui;

import log.LogItem;

import javax.swing.*;
import javax.swing.event.TableColumnModelListener;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;

public class LogTableColumnModel implements TableColumnModel
{
    @Override
    public void addColumn(TableColumn aColumn) {
    }

    @Override
    public void removeColumn(TableColumn column) {
    }

    @Override
    public void moveColumn(int columnIndex, int newIndex) {

    }

    @Override
    public void setColumnMargin(int newMargin) {

    }

    @Override
    public int getColumnCount() {
        return LogItem.Field.values().length;
    }

    @Override
    public Enumeration<TableColumn> getColumns() {
        return Collections.enumeration(_tableColumns);
    }

    @Override
    public int getColumnIndex(Object columnIdentifier) {
        return 0;
    }

    @Override
    public TableColumn getColumn(int columnIndex) {
        return _tableColumns.get(columnIndex);
    }

    @Override
    public int getColumnMargin() {
        return 3;
    }

    @Override
    public int getColumnIndexAtX(int xPosition) {
        return 0;
    }

    @Override
    public int getTotalColumnWidth() {
        return -1;
    }

    @Override
    public void setColumnSelectionAllowed(boolean flag) {
    }

    @Override
    public boolean getColumnSelectionAllowed() {
        return false;
    }

    @Override
    public int[] getSelectedColumns() {
        return new int[0];
    }

    @Override
    public int getSelectedColumnCount() {
        return 0;
    }

    @Override
    public void setSelectionModel(ListSelectionModel newModel) {
        _selectionModel = newModel;
    }

    @Override
    public ListSelectionModel getSelectionModel() {
        return _selectionModel;
    }

    @Override
    public void addColumnModelListener(TableColumnModelListener x) {
    }

    @Override
    public void removeColumnModelListener(TableColumnModelListener x) {

    }

    public LogTableColumnModel()
    {
        _tableColumns.add(new TableColumn(LogItem.Field.Index.ordinal(), 80));
        _tableColumns.add(new TableColumn(LogItem.Field.Time.ordinal(), 150));
        _tableColumns.add(new TableColumn(LogItem.Field.Level.ordinal(), 80));
        _tableColumns.add(new TableColumn(LogItem.Field.Tag.ordinal(), 80));
        _tableColumns.add(new TableColumn(LogItem.Field.Message.ordinal(), 800));
        _tableColumns.add(new TableColumn(LogItem.Field.Pid.ordinal(), 80));
        _tableColumns.add(new TableColumn(LogItem.Field.Tid.ordinal(), 80));
        _tableColumns.add(new TableColumn(LogItem.Field.Module.ordinal(), 100));
        _tableColumns.add(new TableColumn(LogItem.Field.File.ordinal(), 100));
        _tableColumns.add(new TableColumn(LogItem.Field.Line.ordinal(), 80));

    }

    private final ArrayList<TableColumn> _tableColumns = new ArrayList<TableColumn>();
    private ListSelectionModel _selectionModel;
}
